# -*- coding: utf-8 -*-

from PyQt4 import QtGui
from question import Question
from answerWidgets import AnswerLine, MatchingLabel

class Matching(Question):
    def __init__(self):
        super(Matching, self).__init__()
        
        self.questionName = self.tr("Matching question")
        self.setObjectName("Matching")
        self.answers.setScheme((AnswerLine, MatchingLabel, AnswerLine))
        self.answers.setPrefix("=")
        self.defaultAnswers = 3


    def validateQuestion(self):
        """ kontrola validity otazky """

        # minimalne tri pary odpovedi musi byt vyplneny
        answers = self.answersBox.findChildren(QtGui.QLineEdit)[:6]
        if len(answers) >= 6:
            for answer in answers:
                if answer.text() == "":
                    self.errors.append(self.tr("There must be at least three matching pairs."))
                    break

        if self.questionText.toPlainText() == "":
            self.errors.append(self.tr("You didn't write text of question."))
